home *** CD-ROM | disk | FTP | other *** search
- // MIOTDREM - Command processor
- // ----------------------------
- //
- // Copyright (c) 1991, Stuart G. Phillips. All rights reserved.
- //
- // Permission is granted for non-commercial use of this software.
- // You are expressly prohibited from selling this software in any form,
- // distributing it with another product, or removing this notice.
- // THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- // IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- // WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- // PURPOSE.
- //
- // This module contains the command processor for the MIO version of
- // TDREMOTE. The procedure tdr_processor() acts as a dispatcher for
- // incoming commands. Actual execution of each command is handled in
- // other modules (grouped by function type). tdr_processor() responds
- // with appropriate response to incoming commands that are not fully
- // supported in the MIO environment (e.g. Requests for file access etc).
- //
- //
-
-
- #include "miotdr.h"
-
-
- // Globals
-
- struct td_imsg *msgq = (struct td_imsg *) NULL;
-
-
- void tdr_processor()
- {
- struct td_omsg *txb = (struct td_omsg *) tx_buffer;
- unsigned int status;
-
- while (1){
- if (msgq == (struct td_imsg *) NULL) continue;
-
- switch (msgq->cmd){
- case TD_SYNC: // Initial greeting - say Hello !
-
- txb->td_sync.code = TD_SYNC;
- txb->td_sync.cpu = TD_80186;
- txb->td_sync.i8087 = NO_8087;
- txb->td_sync.version = TD_VERSION;
-
- send((unsigned char *)txb, sizeof(txb->td_sync));
- break;
-
- case TD_SENDFILE: // Unsupported - receive file from host
-
- txb->td_sendfile.status = FALSE;
- send((unsigned char *)txb, sizeof(txb->td_sendfile));
- break;
-
- case TD_GETFINFO: // Get file information
-
- txb->td_getfinfo.filetime = *((long *)0xfc);
- send((unsigned char *)txb, sizeof(txb->td_getfinfo));
- break;
-
- case TD_GO: // Execute the program
-
- status = go_program();
- if (status != TD_SSTOP){
- txb->td_stopped.state = (unsigned char) status;
- txb->td_stopped.term_code = 0;
- txb->td_stopped.i8087 = NO_8087;
- send((unsigned char *)txb, sizeof(txb->td_stopped));
- }
- break;
-
- case TD_STOP: // Stop execution
- // Already processed and acknowledged
- break;
-
- case TD_READMEM: // Read memory
-
- read_memory(msgq->data.td_readmem.segment,
- msgq->data.td_readmem.offset,
- msgq->data.td_readmem.count);
- break;
-
- case TD_WRITEMEM: // Write memory
-
- write_memory(msgq->data.td_writemem.segment,
- msgq->data.td_writemem.offset,
- msgq->data.td_writemem.count,
- msgq->data.td_writemem.data);
- break;
-
- case TD_READIO: // Read IO port
-
- read_io(msgq->data.td_readio.port,
- msgq->data.td_readio.word_or_byte);
- break;
-
- case TD_WRITEIO: // Write IO port
-
- write_io(msgq->data.td_writeio.port,
- msgq->data.td_writeio.word_or_byte,
- msgq->data.td_writeio.value);
- break;
-
- case TD_READREGS: // Read processor registers
-
- read_regs();
- break;
-
- case TD_WRITEREGS: // Write processor registers
-
- write_regs(&msgq->data.td_write_regs.regs);
- break;
-
- case TD_READFP: // Read floting point status
- case TD_WRITEFP: // Write floating point status
- // Since we told the host end there was no numeric
- // coprocessor, it shouldn't read or write the status...
- // ...right ?
-
- send_ack();
- break;
-
- case TD_LOADPROG: // Load program into remote memory
-
- // We presume that the program has already been loaded
- // using MIOLOAD and that it is loaded at 0000:0100
- // on up. So we tell a white lie and tell the host
- // end that this operation was successful.
-
- txb->td_loadprog.status = 0;
- txb->td_loadprog.pid = 0;
- txb->td_loadprog.i8087 = FALSE;
-
- // Nuke the timestamp at 0000:00FC so that any attempts
- // to restart the program are guaranteed NOT to work.
-
- *((long *)0xfc) = 0;
-
- send((unsigned char *)txb, sizeof(txb->td_loadprog));
- break;
-
- case TD_MAKEPSP: // Make a PSP
-
- // Since we're not running DOS on MIO, there is no
- // concept of a PSP. We also assume that the MIO
- // start up routine takes care of assumptions about the
- // machine environment such as stack, data segment etc.
- // We ignore this command completely.
-
- send_ack();
- break;
-
- case TD_PROGFREE: // Free program memory
-
- // Another DOS related concept with no MIO analogy.
- // We also ignore this command !
-
- send_ack();
- break;
-
- case TD_MEMSET: // Set a block of memory
-
- set_mem(msgq->data.td_memset.segment,
- msgq->data.td_memset.offset,
- msgq->data.td_memset.count,
- msgq->data.td_memset.value);
- break;
-
- case TD_MEMCPY: // Copy a block of memory
-
- copy_mem(msgq->data.td_memcopy.src_segment,
- msgq->data.td_memcopy.src_offset,
- msgq->data.td_memcopy.dst_segment,
- msgq->data.td_memcopy.dst_offset,
- msgq->data.td_memcopy.count);
- break;
-
- case TD_GETPINFO: // Get program information
-
- txb->td_getpinfo.mem_dos = 0;
- txb->td_getpinfo.mem_debugger = 0;
- txb->td_getpinfo.mem_symbols = 0;
- txb->td_getpinfo.mem_program = 0;
- txb->td_getpinfo.mem_available = 0;
- txb->td_getpinfo.ems_dos = 0;
- txb->td_getpinfo.ems_debugger = 0;
- txb->td_getpinfo.ems_program = 0;
- txb->td_getpinfo.ems_available = 0;
- txb->td_getpinfo.dos_version = 0;
- txb->td_getpinfo.hardware_bkpts = 0;
- txb->td_getpinfo.ems_present = 0;
- for (int i = 0; i < VECCOUNT; i++)
- txb->td_getpinfo.intflags[i] = 0;
-
- send((unsigned char *)txb,sizeof(txb->td_getpinfo));
- break;
-
- case TD_OVLHOOK: // Set PASCAL overlay hook
-
- // Not supported - just say we did it and carry on
-
- send_ack();
- break;
-
- case TD_BYE: // Remote has signalled end of session
-
- send_ack();
- break;
-
- default: // Oh what to do ?!
-
- send_ack();
- break;
- }
-
- msgq = (struct td_imsg *) NULL;
- }
- }
-
-
-